﻿#pragma once

#include "MainPage.g.h"


namespace winrt::NovelReader::implementation
{
    struct MainPage : MainPageT<MainPage>
    {
    public:
        MainPage();
        void InitializeComponent(); 
        winrt::NovelReader::MainPageViewModel ViewModel(); 

        void AutoSuggestBox_TextChanged(winrt::Microsoft::UI::Xaml::Controls::AutoSuggestBox const& sender, winrt::Microsoft::UI::Xaml::Controls::AutoSuggestBoxTextChangedEventArgs const& args);
        void AutoSuggestBox_SuggestionChosen(winrt::Microsoft::UI::Xaml::Controls::AutoSuggestBox const& sender, winrt::Microsoft::UI::Xaml::Controls::AutoSuggestBoxSuggestionChosenEventArgs const& args);
        void Page_ActualThemeChanged(winrt::Microsoft::UI::Xaml::FrameworkElement const& sender, winrt::Windows::Foundation::IInspectable const& args);
        void ScrollReader(winrt::NovelReader::ScrollDirection direction);
        void OnViewModelPropertiesChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::Data::PropertyChangedEventArgs const& args); 
        void EnableAutoTurnPage(bool value); 
        void ChapterTextScrollView_ViewChanged(winrt::Microsoft::UI::Xaml::Controls::ScrollView const& sender, winrt::Windows::Foundation::IInspectable const& args);

    private:
        void UpdateRichTextBlock(); 
        void OnTimerTick(winrt::Windows::Foundation::IInspectable const&, winrt::Windows::Foundation::IInspectable const&); 
        void GotoPreviousChapter(); 
        void GotoNextChapter(); 

        winrt::NovelReader::MainPageViewModel m_viewModel {nullptr}; 
        winrt::NovelReader::Settings m_userSettings {nullptr}; 
        winrt::Microsoft::UI::Xaml::DispatcherTimer m_timer{nullptr}; 
        bool m_isChapterFinished {false}; 
        bool m_isFirst{ true }; 
    };
}

namespace winrt::NovelReader::factory_implementation
{
    struct MainPage : MainPageT<MainPage, implementation::MainPage>
    {
    };
}
